from gaevents.models import Gaevent
from gaevents.models import Gaeventlocation
from django.contrib import admin
from gausers.models import Gauser
from gaevents.models import Gabusiness
from gaevents.models import Gabizlocation

class GabizlocationAdmin(admin.ModelAdmin):

  fieldsets = [
    ('Address',                 {'fields': ['address_1', 'city', 'state', 'zip', 'country']}),
    ('Details',                 {'fields': ['latitude', 'longitude']}),

  ]

class GaeventInline(admin.TabularInline): #also try out tabular
  model = Gaevent
  fieldsets = [
    ('Basic Info',              {'fields': ['eventname', ('eventstartdate', 'eventstarttime'), ('eventenddate', 'eventendtime'), 'eventdescription', 'tickets', 'supportemail', 'supportphone'] , 'classes':['collapse']}),

  ]
  extra = 0

class BizLocationInline(admin.StackedInline):
  model = Gabizlocation
  fieldsets = [
    ('Address',                 {'fields': ['address_1', 'city', 'state', 'zip', 'country', 'latitude', 'longitude'], 'classes': ['collapse']}),

  ]

class GabusinessAdmin(admin.ModelAdmin):
  #fields = ['eventname', 'eventstartdate', 'eventstarttime']
  fieldsets = [
    (None,                         {'fields': ['bizname',]}),
    ('Contact',     		   {'fields' : [('contactname', 'contactemail'), 'supportemail', 'phonenumber', 'faxnumber'] }),
    #('Basic Info',              {'fields': ['eventdescription', 'tickets', 'supportemail', 'supportphone'] }),
    #('Location',                 {'fields': ['gaeventlocation']})
  ]
  list_display = ('bizname', )
  #list_filter  = ('',)
  search_fields = ['bizname']
  inlines = [BizLocationInline, GaeventInline]


class GaeventlocationAdmin(admin.ModelAdmin):

  fieldsets = [
    ('Address',			{'fields': ['address_1', 'city', 'state', 'zip']}),
    ('Details',			{'fields': ['latitude', 'longitude']}),

  ]
  
class LocationInline(admin.StackedInline):
  model = Gaeventlocation
  fieldsets = [
    ('Address',                 {'fields': ['address_1', 'city', 'state', 'zip', 'country']}),
    ('Details',                 {'fields': ['latitude', 'longitude']}),

  ] 

class GaeventAdmin(admin.ModelAdmin):
  #fields = ['eventname', 'eventstartdate', 'eventstarttime']
  fieldsets = [
    ('Date Information',        {'fields' : [('eventname', 'eventstartdate', 'eventstarttime'), ('eventenddate', 'eventendtime')], 'classes':['collapse']  }),
    ('Basic Info',		{'fields': ['eventdescription', 'tickets', 'supportemail', 'supportphone'] , 'classes':['collapse']}),
    #('Location',                 {'fields': ['gaeventlocation']})
  ]
  list_display = ('eventname', 'eventstartdate', 'eventstarttime', 'eventdescription')
  list_filter  = ('eventstartdate', 'eventname')
  search_fields = ['eventname']
  date_hierarchy = 'eventstartdate'
  inlines = [LocationInline]

class GaeventInline(admin.TabularInline):
  model = Gaevent
  fieldsets = [
    (None,			{'fields': ['eventname']}),

  ]

admin.site.register(Gabizlocation, GabizlocationAdmin)
admin.site.register(Gabusiness, GabusinessAdmin)
admin.site.register(Gaeventlocation, GaeventlocationAdmin)
admin.site.register(Gaevent, GaeventAdmin)
